<?php
namespace app\index\controller;
use think\Controller;

use think\Db;

use app\lib\aliyun\Sms as aliSms;


class Plan extends Controller
{   
    public function sendOrdersSms(){
        $nextdate = date('Y-m-d',strtotime('+1 days'));
        $list = Db::name('orders')->where('lesson_date',$nextdate)->select();
        foreach ($list as $k => $vo) {
            $service = Db::name('service')->where('uuid',$vo['service_uuid'])->find();
            if ($vo['lesson_type'] == 0) {
                $message = "溫馨提醒 : 明天預約了【".$service['name']."】服務\n\r香港時間：".smsTimeFormat($vo['lesson_date'],$vo['lesson_time'])."\n\r服務以Whatsapp video call進行,請提前準備安靜及不受打擾的環境,準時等候聯絡";
            }else{
                $classroom_address = Db::name('classroom')->where('uuid',$save_data['classroom_uuid'])->value('address');
                $message = "溫馨提醒 : 明天預約了【".$service['name']."】服務\n\r時間：".smsTimeFormat($save_data['lesson_date'],$save_data['lesson_time'])."\n\r地址：".$classroom_address;
            }
            $uinfo = Db::name('user')->field('area_code,mobile')->where('uuid',$vo['user_uuid'])->find();
            $smsresult = aliSms::send($uinfo['area_code'].$uinfo['mobile'],$message);
        }
    }


}
